<template>
  <div class="app-container">
    <div class="change">
      <p>
        <span>回款日期</span>
        <el-input v-model="tempData.huikuanriqi" class="userselect" type="text" placeholder="请输入回款日期"/>
      </p>
      <p>
        <span>结汇银行</span>
        <el-input v-model="tempData.jiehuiyinhang" type="text" class="userselect" placeholder="请输入结汇银行" />
      </p>
      <p>
        <span>洲别</span>
        <el-input v-model="tempData.zhoubie" type="text" class="userselect" placeholder="请输入洲别" />
      </p>
			<p>
        <span>回款金额</span>
        <el-input v-model="tempData.huikuanjine" class="userselect" type="text" placeholder="请输入回款金额" />
      </p>
			<p>
        <span>备用金额</span>
        <el-input v-model="tempData.jine" class="userselect" type="text" placeholder="请输入备用金额" />
      </p>
			<p>
        <span>实际使用金额</span>
        <el-input v-model="tempData.shijishiyong" type="text" class="userselect" placeholder="请输入实际使用金额" />
      </p>
			<!-- <p>
        <span>导入时间</span>
        <el-input v-model="tempData.insertTime" type="text" class="userselect" placeholder="请输入导入时间" />
      </p> -->
    </div>
		<div class="submits">
		  <div class="save" :class="isClick ? 'disable' : ''" @click="save" v-if="!islook">保存</div>
		  <div class="nosave" @click="nosave">取消</div>
		</div>
  </div>
</template>

<script>
import { addTichengHuikuan,updateTichengHuikuan } from '@/api/waimao'
export default {
  data(){
    return{
      tempData: {},
			writeOradd: 0,   //新增0,修改1
			islook: false,
			isClick: false
    }
  },
  mounted(){
		console.log(this.$route.params)
		if(this.$route.params.look){
      this.islook = true
    }else{
      this.islook = false
    }
    if(this.$route.params.options){
      this.tempData = JSON.parse(this.$route.params.options)
      this.writeOradd = 1
    }else{
      this.writeOradd = 0
    }
  },
  methods:{
    save(){
			this.isClick = true
      if(this.writeOradd == 0){
        addTichengHuikuan(this.tempData).then(res => {
          this.$message({
            message: res.message,
            type: 'success'
          })
          this.$router.go(-1)
          console.log(res)
        })
      }else{
        updateTichengHuikuan(this.tempData).then(res => {
          this.$message({
            message: res.message,
            type: 'success'
          })
          this.$router.go(-1)
          console.log(res)
        })
      }
    },
    nosave(){
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped lang="scss">
  .submits {
	  display: flex;
		background: #fff;
	  padding: 20px 20px;
		border-radius: 8px;
		margin-top: 20px;
		// border-top: 1px solid #ccc;
	  justify-content: flex-end;
	  align-items: center;
	  > div {
	    width: 80px;
	    height: 32px;
	    text-align: center;
	    line-height: 32px;
	    color: #fff;
	    font-size: 14px;
	    border-radius: 4px;
	    margin-left: 30px;
	    cursor: pointer;
	  }
	  .save {
	    background: #18a05e;
	  }
	  .nosave {
	    background: #999;
	  }
	}
  .change {
	  display: flex;
	  flex-wrap: wrap;
	  background: #fff;
	  border-radius: 8px;
	  padding: 20px 0;
	  > p {
	    width: 33%;
	    font-size: 14px;
      padding: 0 10px;
	    display: flex;
	    align-items: center;
	    color: #333;
	    /deep/.el-input__inner {
	      // width: inherit;
	      background: none;
	      height: 32px;
	      // line-height: 32px;
	      color: #333;
	      border: 1px solid rgba(0, 0, 0, 0.1);
	      padding: 0 25px;
	    }
	    /deep/.el-input__icon {
	      line-height: 32px;
	    }
	    .userselect {
	      // max-width: 250px;
	      flex: 1;
	    }
	
	    > span {
	      display: block;
	      width: 100px;
	      text-align: right;
	      padding-right: 15px;
	    }
	    > input {
	      width: inherit;
	      flex: 1;
	      height: 32px;
	      border-radius: 3px;
	      border: 1px solid rgba(0, 0, 0, 0.1);
	      padding-left: 10px;
	      color: #333;
	    }
	  }
	}
</style>